package com.vitas.coin.ui.act

import android.graphics.Color
import com.snap.base.ktx.enterBuy
import com.snap.base.ktx.isEnableConfigWithKey
import com.snap.base.ktx.isSupportAliPay
import com.snap.base.ktx.isSupportWxPay
import com.snap.base.util.BaseUtil
import com.snap.common.databinding.view.ViewBindingAdapter.gone
import com.snap.common.main.BaseMVVMAct
import com.snap.util.edge.EdgeUtils.edgeSetNavigationBarColorInt
import com.snap.util.edge.EdgeUtils.edgeSetStatusBarLight
import com.snap.util.edge.paddingBottomSystemWindowInsets
import com.snap.util.edge.paddingTopSystemWindowInsets
import com.snap.view.ActionBarAdapter.setBack
import com.vitas.coin.R
import com.vitas.coin.constant.AdConfig
import com.vitas.coin.databinding.ActBuyBinding
import com.vitas.coin.vm.BuyVM
import com.vitas.coin.vm.RyPriceVM

class BuyAct : BaseMVVMAct<ActBuyBinding, BuyVM>() {

    override fun createVM(): BuyVM {
        return BuyVM().apply {
            back = { finish() }
            actionAct = { this@BuyAct }
        }
    }

    override fun doDataBind() {
        binding.ryPriceVM = RyPriceVM()
        binding.viewModel = viewModel
    }

    override fun getContentViewId(): Int {
        return R.layout.act_buy
    }

    override fun onCreate() {
        BaseUtil.enterBuy(true)

        edgeSetStatusBarLight(false)
        edgeSetNavigationBarColorInt(Color.parseColor("#01000000"))

        binding.flContent.paddingBottomSystemWindowInsets()
        binding.actionBar.paddingTopSystemWindowInsets()
        binding.actionBar.setBack { finish() }

        binding.llPayWx.gone(!BaseUtil.isSupportWxPay())
        binding.llPayAli.gone(!BaseUtil.isSupportAliPay())
        if (BaseUtil.isSupportWxPay()) {
            viewModel.payWay.value = 1
        } else if (BaseUtil.isSupportAliPay()) {
            viewModel.payWay.value = 2
        }

        binding.llBuyDesc.gone(true)
        if (BaseUtil.isEnableConfigWithKey(AdConfig.SHOW_BUY_DESC)) {
            binding.llBuyDesc.gone(false)
        }
    }

}